package com.hjj.controller;

import com.hjj.beans.Type;
import com.hjj.dto.ResultDTO;
import com.hjj.services.TypeServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/type")
public class TypeController {
    @Autowired
    TypeServices typeServices;

    @RequestMapping(value = "getAll.action", method = RequestMethod.GET)
    public ResultDTO getAll(){
        ArrayList<Type> all = typeServices.getAll();

        // 封装数据传输对象DTO
        ResultDTO resultDTO = new ResultDTO();
        resultDTO.setResult(ResultDTO.SUCCESS);
        resultDTO.setReason("查询成功");
        resultDTO.setData(all);

        return resultDTO;
    }
}
